import 'package:flutter/material.dart';
import 'package:my_app/common/common.dart';
import 'package:my_app/global/global.dart';
import 'package:my_app/home/demo.dart';
import 'package:my_app/login/login.dart';
import 'package:my_app/qr_list_menu/qr_list_menu.dart';
import 'package:my_app/single/input_goods_code.dart';
import 'package:my_app/single/single.dart';
import 'package:my_app/multiple/multiple.dart';

class Menu extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    double getHeight() {
      MediaQueryData mq;
      mq = MediaQuery.of(context);
      // 设备宽度
      double deviceWidth = mq.size.width;
      double width = 210; // 列表内容大小
      if (deviceWidth > 360) {
        width = 30;
      } else {
        width = 20;
      }
      return width;
    }

    int _muji = Common.muji;
    final ButtonStyle buttonStyle = Common.buttonStyle;
    TextStyle buttonTextStyle = Common.buttonTextStyle;
    return Scaffold(
        appBar: AppBar(
          title: Text('菜单选择'),
          centerTitle: true,
          automaticallyImplyLeading: false,
          backgroundColor: Color(Common.muji),
        ),
        body: ListView(children: [
          Column(
            children: [
              Row(
                children: [
                  SizedBox(
                    width: 5,
                  ),
                  Container(
                    child: Text(DateTime.now().toString().substring(0, 10)),
                  ),
                  SizedBox(
                    width: 20,
                  ),
                  Container(
                    child: Text("登录人:${GlobalData.staffName}"),
                  ),
                ],
              ),
              Center(
                child: Column(
                  // mainAxisAlignment: MainAxisAlignment.start,
                  children: [
                    Container(
                      padding: EdgeInsets.only(top: 40.0, bottom: 10.0),
                      child: Text(
                        "MUJI",
                        style: TextStyle(color: Color(_muji), fontSize: 50.0),
                      ),
                    ),
                    SizedBox(
                      height: getHeight(),
                    ),
                    Container(
                      // color: Colors.red,
                      width: 300,
                      height: 50,
                      child: TextButton(
                        style: buttonStyle,
                        child: Text(
                          "个袋扫描",
                          style: buttonTextStyle,
                        ),
                        onPressed: () => {
                          Navigator.of(context).push(
                            MaterialPageRoute(
                              builder: (context) {
                                return Single(title: 'test1');
                              },
                            ),
                          ),
                        },
                      ),
                    ),
                    SizedBox(
                      height: getHeight(),
                    ),
                    Container(
                      height: 50,
                      width: 300,
                      child: TextButton(
                        style: buttonStyle,
                        child: Text(
                          "卷膜扫描",
                          style: buttonTextStyle,
                        ),
                        onPressed: () => {
                          Navigator.of(context).push(
                            MaterialPageRoute(
                              builder: (context) {
                                return Multiple();
                              },
                            ),
                          ),
                        },
                      ),
                    ),
                    SizedBox(
                      height: getHeight(),
                    ),
                    Container(
                      height: 50,
                      width: 300,
                      child: TextButton(
                        style: buttonStyle,
                        child: Text(
                          "批量扫描",
                          style: buttonTextStyle,
                        ),
                        onPressed: () => {
                          Navigator.of(context).push(
                            MaterialPageRoute(
                              builder: (context) {
                                return InputGoodsCode();
                                // return TimePickerPage();
                              },
                            ),
                          ),
                        },
                      ),
                    ),
                    SizedBox(
                      height: getHeight(),
                    ),
                    Container(
                      height: 50,
                      width: 300,
                      child: TextButton(
                        style: buttonStyle,
                        child: Text(
                          "二维码赋码详情",
                          style: buttonTextStyle,
                        ),
                        onPressed: () => {
                          Navigator.of(context).push(
                            MaterialPageRoute(
                              builder: (context) {
                                return QrListMenu();
                                // return Pulltorefresh();
                              },
                            ),
                          ),
                        },
                      ),
                    ),
                    SizedBox(
                      height: getHeight(),
                    ),
                    Container(
                      // padding: EdgeInsets.only(bottom: 150.0),
                      height: 50,
                      width: 300,
                      child: TextButton(
                        style: buttonStyle,
                        child: Text(
                          "退出登录",
                          style: buttonTextStyle,
                        ),
                        onPressed: () => {
                          Navigator.of(context).pushAndRemoveUntil(
                              //这里面传一个值给Tab页面，从哪个页面跳过来，最后还跳回到哪个页面，这里的1指的就是Setting.dart页面
                              new MaterialPageRoute(
                                  builder: (context) => Login()),
                              (route) => route == null),
                          // Navigator.of(context).push(
                          //   MaterialPageRoute(
                          //     builder: (context) {
                          //       return Login();
                          //       // return TimePickerPage();
                          //     },
                          //   ),
                          // ),
                        },
                      ),
                    ),
                    SizedBox(
                      height: getHeight(),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ]));
  }
}
